library("tidyverse")
library("ggpubr")
library("zoo")
setwd("/mnt/LocalData/behaviour/aDN/aDN_behaviour")
gg_color_hue <- function(n) {
hues = seq(15, 375, length = n + 1)
hcl(h = hues, l = 65, c = 100)[1:n]
}
gg_color_hue(2)
[1] "#F8766D" "#00BFC4"
getwd()
[1] "/mnt/LocalData/behaviour/aDN/aDN_behaviour"
# rawdata_list <- list.files("../",recursive = TRUE) %>% str_subset("_ALLDATA.csv") %>% str_subset("_Male_")
# all_rawdata <- tibble()
# for (rawdata_file in rawdata_list) {
# temp <- read_csv(paste0("../",rawdata_file),progress = FALSE)
# all_rawdata <- bind_rows(all_rawdata,temp)
# }
# # added for testing purposes - function not used in actual code
# female_pos <- function(theta,dist,ori,xmale,xfemale){
# yrel=calculate_yrel(theta,dist)
# xrel=calculate_xrel(ori,xmale,xfemale,yrel)
# return(c(xrel,yrel))
# }
# calculates relative y value based on data from feat.mat
calculate_yrel <- function(theta,dist){
yrel=dist*cos(theta)
return(yrel)
}
calculate_xrel <- function(ori,xmale,xfemale,yrel,ppm=14.85){
xmale_mm=xmale/ppm
xfemale_mm=xfemale/ppm
xrel = (xfemale_mm - (cos(ori)*yrel+xmale_mm))/(sin(ori))
return(xrel)
}
calculate_xrel_abs <- function(theta,dist){
xrel=dist*sin(theta)
return(xrel)
}
unique(all_rawdata$treatment)
[1] "C" "B" "D" "A" NA
100*sum(is.na(all_rawdata$treatment))/nrow(all_rawdata)
[1] 1.449275
unique(all_rawdata$unique_fly[is.na(all_rawdata$treatment)])
[1] "Megan-2019_03_06_Courtship-DsxVglutTNT_Male_1234_2_9" "Megan-2019_03_06_Courtship-DsxVglutTNT_Male_1234_2_10" "Megan-2019_03_06_Courtship-DsxVglutTNT_Male_1234_9_31" "Megan-2019_03_06_Courtship-DsxVglutTNT_Male_1234_9_32"
Megan says through out these individuals from video 1234_2 arena 5 and video 1234_9 arena 16
all_rawdata %>%
filter(FileName == "Megan-2019_03_06_Courtship-DsxVglutTNT_Male_1234_2") %>%
filter(Id == 3) %>%
filter(dist_to_other__mm > 2.5) %>%
summarise(unique_fly = unique(unique_fly),
l_ipsi = sum(wing_l_ang__rad<(-35*pi/180) & rel_x_abs_corr_other<0, na.rm = TRUE)/length(Frame),
r_ipsi = sum(wing_r_ang__rad>(35*pi/180) & rel_x_abs_corr_other>0, na.rm = TRUE)/length(Frame),
l_contra = sum(wing_l_ang__rad<(-35*pi/180) & rel_x_abs_corr_other>0, na.rm = TRUE)/length(Frame),
r_contra = sum(wing_r_ang__rad>(35*pi/180) & rel_x_abs_corr_other<0, na.rm = TRUE)/length(Frame)
)
all_rawdata <- all_rawdata %>%
arrange(FileName,Id,Frame) %>%
group_by(unique_fly) %>%
mutate(rollavg_dist_to_other = rollmean(dist_to_other__mm, 150, fill = c(NA,0,NA), align = c("center")))
all_rawdata
write_csv(all_rawdata,"all_rawdata.csv")
wind <- 600
p1 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(max_wing_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(35*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p2 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
left_wing_index = 100*sum(wing_l_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<(-35*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=left_wing_index)) +
geom_boxplot()
p3 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
right_wing_index = 100*sum(wing_r_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(35*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=right_wing_index)) +
geom_boxplot()
p4 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
both_wing_index = 100*sum(min_wing_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(35*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=both_wing_index)) +
geom_boxplot()
ggarrange(plotlist = list(p1,p4,p2,p3),
labels = c("either wing","both wings","left wing","right wing"),
hjust = -0.6,
vjust = 2,
ncol = 4,
nrow = 1)
wind <- 600
p1 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(max_wing_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(35*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p2 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
ipsi_wing_index = 100*(sum(wing_l_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<(-35*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<=0,
na.rm = TRUE) +
sum(wing_r_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(35*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>=0,
na.rm = TRUE)
)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=ipsi_wing_index)) +
geom_boxplot()
p3 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
contra_wing_index = 100*(sum(wing_l_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<(-35*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>0,
na.rm = TRUE) +
sum(wing_r_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(35*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<0,
na.rm = TRUE)
)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=contra_wing_index)) +
geom_boxplot()
ggarrange(plotlist = list(p1,p2,p3),
labels = c("either wing","ipsi wing","contra wing"),
hjust = -0.6,
vjust = 2,
ncol = 3,
nrow = 1)
wing_thresh <- 15
wind <- 600
p1 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(max_wing_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(wing_thresh*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p2 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
ipsi_wing_index = 100*(sum(wing_l_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<(-wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<=0,
na.rm = TRUE) +
sum(wing_r_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>=0,
na.rm = TRUE)
)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=ipsi_wing_index)) +
geom_boxplot()
p3 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
contra_wing_index = 100*(sum(wing_l_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<(-wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>0,
na.rm = TRUE) +
sum(wing_r_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<0,
na.rm = TRUE)
)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=contra_wing_index)) +
geom_boxplot()
ggarrange(plotlist = list(p1,p2,p3),
labels = c("either wing","ipsi wing","contra wing"),
hjust = -0.6,
vjust = 2,
ncol = 3,
nrow = 1)
wing_thresh <- 15
wind <- 600
p1 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(max_wing_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(wing_thresh*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p2 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
ipsi_wing_index = 100*(sum(wing_l_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<(-wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<=0,
na.rm = TRUE) +
sum(wing_r_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>=0,
na.rm = TRUE)
)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)
) %>%
ggplot(aes(x=genotype,y=ipsi_wing_index)) +
geom_boxplot()
p3 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
contra_wing_index = 100*(sum(wing_l_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<(-wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>0,
na.rm = TRUE) +
sum(wing_r_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<0,
na.rm = TRUE)
)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=contra_wing_index)) +
geom_boxplot()
p4 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
ratio = ((sum(wing_l_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<(-wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<=0,
na.rm = TRUE) +
sum(wing_r_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>=0,
na.rm = TRUE)
)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)
)/
((sum(wing_l_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<(-wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>0,
na.rm = TRUE) +
sum(wing_r_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<0,
na.rm = TRUE)
)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)
)
) %>%
ggplot(aes(x=genotype,y=ratio)) +
geom_boxplot()
ggarrange(plotlist = list(p1,p2,p3,p4),
labels = c("either wing","ipsi wing","contra wing","ipsi:contra"),
hjust = -0.6,
vjust = 2,
ncol = 4,
nrow = 1)
all_rawdata <- all_rawdata %>% select(-ipsi_wing,-contra_wing)
all_rawdata <- all_rawdata %>%
mutate(ipsi_wing = if_else(((wing_l_ang__rad<(-15*pi/180) &
rel_x_abs_corr_other<=0) |
(wing_r_ang__rad>(15*pi/180) &
rel_x_abs_corr_other>=0)),1,0),
contra_wing = if_else(((wing_l_ang__rad<(-15*pi/180) &
rel_x_abs_corr_other>0) |
(wing_r_ang__rad>(15*pi/180) &
rel_x_abs_corr_other<0)),1,0)
) %>%
replace_na(list(ipsi_wing = 0)) %>%
replace_na(list(contra_wing = 0))
all_rawdata
p1 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
ipsi_wing_index = 100*(sum(wing_l_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<(-wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<=0,
na.rm = TRUE) +
sum(wing_r_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>=0,
na.rm = TRUE)
)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)
) %>%
ggplot(aes(x=genotype,y=ipsi_wing_index)) +
geom_boxplot()
p2 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
contra_wing_index = 100*(sum(wing_l_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<(-wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>0,
na.rm = TRUE) +
sum(wing_r_ang__rad[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]>(wing_thresh*pi/180) &
rel_x_abs_corr_other[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]<0,
na.rm = TRUE)
)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=contra_wing_index)) +
geom_boxplot()
p3 <- all_rawdata %>%
filter(genotype != "CS") %>%
#filter(max_wing_ang__rad > (35*pi/180)) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(ipsi_wing[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
],
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p4 <- all_rawdata %>%
filter(genotype != "CS") %>%
#filter(max_wing_ang__rad > (35*pi/180)) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(contra_wing[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
],
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
ggarrange(plotlist = list(p1,p3,p2,p4),
labels = c("ipsi raw","ipsi column","contra raw","contra column"),
hjust = -0.6,
vjust = 2,
ncol = 2,
nrow = 2)
p1 <- all_rawdata %>%
filter(genotype != "CS") %>%
filter(max_wing_ang__rad > (15*pi/180)) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(ipsi_wing[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
],
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p2 <- all_rawdata %>%
filter(genotype != "CS") %>%
filter(max_wing_ang__rad > (20*pi/180)) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(ipsi_wing[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
],
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p3 <- all_rawdata %>%
filter(genotype != "CS") %>%
filter(max_wing_ang__rad > (25*pi/180)) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(ipsi_wing[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
],
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p4 <- all_rawdata %>%
filter(genotype != "CS") %>%
filter(max_wing_ang__rad > (30*pi/180)) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(ipsi_wing[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
],
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p5 <- all_rawdata %>%
filter(genotype != "CS") %>%
filter(max_wing_ang__rad > (35*pi/180)) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(ipsi_wing[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
],
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
ggarrange(plotlist = list(p1,p3,p2,p4,p5),
labels = c("ipsi, >15deg","ipsi, >20deg","ipsi, >25deg","ipsi, >30deg","ipsi, >35deg"),
hjust = 0,
vjust = 2,
ncol = 5,
nrow = 1)
p1 <- all_rawdata %>%
filter(genotype != "CS") %>%
filter(max_wing_ang__rad > (15*pi/180)) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(contra_wing[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
],
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p2 <- all_rawdata %>%
filter(genotype != "CS") %>%
filter(max_wing_ang__rad > (20*pi/180)) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(contra_wing[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
],
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p3 <- all_rawdata %>%
filter(genotype != "CS") %>%
filter(max_wing_ang__rad > (25*pi/180)) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(contra_wing[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
],
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p4 <- all_rawdata %>%
filter(genotype != "CS") %>%
filter(max_wing_ang__rad > (30*pi/180)) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(contra_wing[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
],
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p5 <- all_rawdata %>%
filter(genotype != "CS") %>%
filter(max_wing_ang__rad > (35*pi/180)) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(contra_wing[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
],
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*600)),
which.max(SmoothedCopulation),
(which.max(SmoothedCourtship)+(25*600))),
(which.max(SmoothedCourtship)+(25*600))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
ggarrange(plotlist = list(p1,p3,p2,p4,p5),
labels = c("contra, >15deg","contra, >20deg","contra, >25deg","contra, >30deg","contra, >35deg"),
hjust = 0,
vjust = 2,
ncol = 5,
nrow = 1)
all_rawdata <- all_rawdata %>%
mutate(ipsi_wing_ang = if_else(rel_x_abs_corr_other>0,
wing_r_ang__rad,
wing_l_ang__rad),
contra_wing_ang = if_else(rel_x_abs_corr_other<0,
wing_r_ang__rad,
wing_l_ang__rad)
)
all_rawdata
wind <- 600
p1 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(abs(ipsi_wing_ang[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
])>(15*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p2 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(abs(ipsi_wing_ang[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
])>(20*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p3 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(abs(ipsi_wing_ang[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
])>(25*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p4 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(abs(ipsi_wing_ang[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
])>(30*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p5 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(abs(ipsi_wing_ang[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
])>(35*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
ggarrange(plotlist = list(p1,p3,p2,p4,p5),
labels = c("ipsi, >15deg","ipsi, >20deg","ipsi, >25deg","ipsi, >30deg","ipsi, >35deg"),
hjust = 0,
vjust = 2,
ncol = 5,
nrow = 1)
wind <- 600
p1 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(abs(contra_wing_ang[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
])>(15*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p2 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(abs(contra_wing_ang[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
])>(20*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p3 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(abs(contra_wing_ang[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
])>(25*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p4 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(abs(contra_wing_ang[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
])>(30*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
p5 <- all_rawdata %>%
filter(genotype != "CS") %>%
group_by(genotype) %>%
group_by(unique_fly) %>%
summarise(genotype = unique(genotype),
wing_index = 100*sum(abs(contra_wing_ang[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
])>(35*pi/180),
na.rm = TRUE)/
length(Frame[which.max(SmoothedCourtship):ifelse(which.max(SmoothedCopulation) > which.max(SmoothedCourtship),
ifelse(which.max(SmoothedCopulation) <= (which.max(SmoothedCourtship)+(25*wind)),
which.max(SmoothedCopulation),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
),
min((which.max(SmoothedCourtship)+(25*wind)),max(Frame))
)
]
)) %>%
ggplot(aes(x=genotype,y=wing_index)) +
geom_boxplot()
ggarrange(plotlist = list(p1,p3,p2,p4,p5),
labels = c("contra, >15deg","contra, >20deg","contra, >25deg","contra, >30deg","contra, >35deg"),
hjust = 0,
vjust = 2,
ncol = 5,
nrow = 1)
all_rawdata <- all_rawdata %>%
mutate(ipsi_wing_len = if_else(rel_x_abs_corr_other>0,
wing_r_len__px,
wing_l_len__px),
contra_wing_len = if_else(rel_x_abs_corr_other<0,
wing_r_len__px,
wing_l_len__px)
)
all_rawdata
temp <- all_rawdata %>%
filter(dist_to_other__mm > 2.5) %>%
filter(dist_to_other__mm < 10) %>%
filter(max_wing_ang__rad < (2*pi/3)) %>%
filter(min_wing_ang__rad >= (0)) %>%
filter(wing_l_ang__rad > (-2*pi/3)) %>%
filter(wing_r_ang__rad < (2*pi/3)) %>%
filter(wing_l_ang__rad <= 0) %>%
filter(wing_r_ang__rad >= 0) %>%
filter(dist_to_wall__mm > 2) #%>%
#filter(max_wing_ang__rad > (15*pi/180))
p1 <- temp %>%
filter(genotype == "A") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(0,1000),na.value = "white") +
theme_void() +
coord_polar()
p2 <- temp %>%
filter(genotype == "B") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(0,1000),na.value = "white") +
theme_void() +
coord_polar()
p3 <- temp %>%
filter(genotype == "C") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(0,1000),na.value = "white") +
theme_void() +
coord_polar()
p4 <- temp %>%
filter(genotype == "D") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(0,1000),na.value = "white") +
theme_void() +
coord_polar()
ggarrange(plotlist = list(p1,p2,p3,p4),
labels = c("A","B","C","D"),
#hjust = 1,
ncol = 2,
nrow = 2)
rm(temp)
temp <- all_rawdata %>%
filter(dist_to_other__mm > 2.5) %>%
filter(dist_to_other__mm < 10) %>%
filter(max_wing_ang__rad < (2*pi/3)) %>%
filter(min_wing_ang__rad >= (0)) %>%
filter(wing_l_ang__rad > (-2*pi/3)) %>%
filter(wing_r_ang__rad < (2*pi/3)) %>%
filter(wing_l_ang__rad <= (0)) %>%
filter(wing_r_ang__rad >= (0)) %>%
filter(dist_to_wall__mm > 2) %>%
filter(max_wing_ang__rad > (15*pi/180))
p1 <- temp %>%
filter(genotype == "A") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(0,1000),na.value = "white") +
theme_void() +
coord_polar()
p2 <- temp %>%
filter(genotype == "B") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(0,1000),na.value = "white") +
theme_void() +
coord_polar()
p3 <- temp %>%
filter(genotype == "C") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(0,1000),na.value = "white") +
theme_void() +
coord_polar()
p4 <- temp %>%
filter(genotype == "D") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(0,1000),na.value = "white") +
theme_void() +
coord_polar()
ggarrange(plotlist = list(p1,p2,p3,p4),
labels = c("A","B","C","D"),
#hjust = 1,
ncol = 2,
nrow = 2)
rm(temp)
temp <- all_rawdata %>%
filter(dist_to_other__mm > 2.5) %>%
filter(dist_to_other__mm < 10) %>%
filter(max_wing_ang__rad < (2*pi/3)) %>%
filter(min_wing_ang__rad >= (0)) %>%
filter(wing_l_ang__rad > (-2*pi/3)) %>%
filter(wing_r_ang__rad < (2*pi/3)) %>%
filter(wing_l_ang__rad <= (0)) %>%
filter(wing_r_ang__rad >= (0)) %>%
filter(dist_to_wall__mm > 2) %>%
filter(max_wing_ang__rad > (15*pi/180))
p1 <- temp %>%
filter(genotype == "A") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(10,1000),na.value = "white") +
theme_void() +
coord_polar()
p2 <- temp %>%
filter(genotype == "B") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(10,1000),na.value = "white") +
theme_void() +
coord_polar()
p3 <- temp %>%
filter(genotype == "C") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(10,1000),na.value = "white") +
theme_void() +
coord_polar()
p4 <- temp %>%
filter(genotype == "D") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(10,1000),na.value = "white") +
theme_void() +
coord_polar()
ggarrange(plotlist = list(p1,p2,p3,p4),
labels = c("A","B","C","D"),
#hjust = 1,
ncol = 2,
nrow = 2)
rm(temp)
temp <- all_rawdata %>%
filter(dist_to_other__mm > 2.5) %>%
filter(dist_to_other__mm < 10) %>%
filter(max_wing_ang__rad < (2*pi/3)) %>%
filter(min_wing_ang__rad >= (0)) %>%
filter(wing_l_ang__rad > (-2*pi/3)) %>%
filter(wing_r_ang__rad < (2*pi/3)) %>%
filter(wing_l_ang__rad <= (0)) %>%
filter(wing_r_ang__rad >= (0)) %>%
filter(dist_to_wall__mm > 2) %>%
filter(min_wing_ang__rad > (15*pi/180))
p1 <- temp %>%
filter(genotype == "A") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(0,500),na.value = "white") +
theme_void() +
coord_polar()
p2 <- temp %>%
filter(genotype == "B") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(0,500),na.value = "white") +
theme_void() +
coord_polar()
p3 <- temp %>%
filter(genotype == "C") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(0,500),na.value = "white") +
theme_void() +
coord_polar()
p4 <- temp %>%
filter(genotype == "D") %>%
ggplot() +
geom_bin2d(aes(x=abs(ipsi_wing_ang), y=ipsi_wing_len), bins = c(200,50)) +
geom_bin2d(aes(x=-abs(contra_wing_ang), y=contra_wing_len), bins = c(200,50)) +
xlim(-pi,pi) +
ylim(0,60) +
scale_fill_continuous(type = "viridis",limits = c(0,500),na.value = "white") +
theme_void() +
coord_polar()
ggarrange(plotlist = list(p1,p2,p3,p4),
labels = c("A","B","C","D"),
#hjust = 1,
ncol = 2,
nrow = 2)
rm(temp)